package com.trayicon.messagenotifier.main.cc;

import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Paint;
import java.awt.RenderingHints;

import javax.swing.JTextField;

public class GradientTextField extends JTextField {
	private Color color1, color2;
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	public GradientTextField() {
		super();
		this.color1 = Color.WHITE;
		this.color2 = Color.GRAY;
		setOpaque(false);
	}
	
	@Override
	public void paint(Graphics g) {
		Graphics2D g2 = (Graphics2D) g;
		g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
				RenderingHints.VALUE_ANTIALIAS_ON);
		int width = getWidth();
		int height = getHeight();
		Paint gradient = new GradientPaint(0, 0, color1, width, height, color2);
		g2.setPaint(gradient);
		g2.fillRect(0, 0, width, height);
		
		super.paintComponent(g);
	}

	public Color getColor1() {
		return color1;
	}

	public void setColor1(Color color1) {
		this.color1 = color1;
	}

	public Color getColor2() {
		return color2;
	}

	public void setColor2(Color color2) {
		this.color2 = color2;
	}

}
